<template>
  <el-form>
    <el-form-item label="Name">
      <el-input v-model.trim="user.name" />
    </el-form-item>
    <el-form-item label="account">
      <el-input v-model.trim="user.account" />
    </el-form-item>
    <el-form-item label="password">
      <el-input show-password v-model.trim="user.password" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">Update</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { updateLogin } from '@/api/user'
export default {
  props: {
    user: {
      type: Object,
      default: () => {
        return {
          name: '',
          password: '',
          account: ''
        }
      }
    }
  },
  created() {
    console.log(this.user)
  },
  methods: {
    submit() {
      updateLogin(this.user).then(response => {
        this.$Modal.success('成功')
      }).catch(error => {
        this.$message({
          message: error,
          type: 'error',
          duration: 5 * 1000
        })
      })
    }
  }
}
</script>
